﻿@model SrBBSPro.Entities.Project
@{
    ViewBag.Title = "项目障害详细";
    Layout = "~/Views/Shared/_LayoutPage.cshtml";
}
<div class="layui-panel" style="position:fixed;left:20px;top:145px">
    <ul class="layui-menu" id="chartMenu">
        <li class="layui-menu-item-group layui-menu-item-down" lay-options="{type: 'group'}">
            <div class="layui-menu-body-title">
                进步状况 <i class="layui-icon layui-icon-up"></i>
            </div>
            <ul>
                <li lay-options="{id: 'EveryDay',txt:'每日障害发生解决状况图表'}">
                    <div class="layui-menu-body-title">每日障害发生解决状况 <i class="fa fa-line-chart"></i></div>
                </li>
                <li lay-options="{id: 'Reviser',txt:'修正人员进步状况图表'}">
                    <div class="layui-menu-body-title">修正人员进步状况 <i class="fa fa-bar-chart"></i></div>
                </li>
                <li lay-options="{id: 'BookDay',txt:'预定日前完成状况图表'}">
                    <div class="layui-menu-body-title">预定日前完成状况 <i class="fa fa-line-chart"></i></div>
                </li>
                <li lay-options="{id: 'Tester',txt:'测试人员状况图表'}">
                    <div class="layui-menu-body-title">测试人员状况 <i class="fa fa-bar-chart"></i></div>
                </li>
            </ul>
        </li>
        <li class="layui-menu-item-divider"></li>
        <li class="layui-menu-item-group layui-menu-item-down" lay-options="{type: 'group'}">
            <div class="layui-menu-body-title">
                品质数据及分析 <i class="layui-icon layui-icon-up"></i>
            </div>
            <ul>
                <li lay-options="{id: 'BugManager',txt:'机能障害对应状况管理表'}">
                    <div class="layui-menu-body-title">机能障害对应状况管理表</div>
                </li>
                <li lay-options="{id: 'ReasonSmall',txt:'机能障害原因统计图表（小）'}">
                    <div class="layui-menu-body-title">机能障害原因统计（小）<i class="fa fa-pie-chart"></i></div>
                </li>
                <li lay-options="{id: 'ReasonBig',txt:'机能障害原因统计图表（大）'}">
                    <div class="layui-menu-body-title">机能障害原因统计（大）<i class="fa fa-pie-chart"></i></div>
                </li>
                <li lay-options="{id: 'Scence',txt:'机能障害现象统计图表'}">
                    <div class="layui-menu-body-title">机能障害现象统计 <i class="fa fa-pie-chart"></i></div>
                </li>
                <li lay-options="{id: 'CodeQuality',txt:'制造担当品质图表'}">
                    <div class="layui-menu-body-title">制造担当品质 <i class="fa fa-bar-chart"></i></div>
                </li>
                <li lay-options="{id: 'TestQuality',txt:'测试担当品质图表'}">
                    <div class="layui-menu-body-title">测试担当品质 <i class="fa fa-bar-chart"></i></div>
                </li>
                <li lay-options="{id: 'SysQuality',txt:'机能品质图表'}">
                    <div class="layui-menu-body-title">机能品质 <i class="fa fa-bar-chart"></i></div>
                </li>
            </ul>
        </li>
    </ul>
</div>
<div class="main layui-clear">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>项目障害</legend>
    </fieldset>
    <div class="layui-form layui-form-pane">
        <input type="hidden" id="pid" />
        <div class="wrap">
            <div class="fly-tab user-tab">
                <span id="tabs">
                    <a id="IT" href="javascript:;" class="tab-this">单体障害</a>
                    <a id="UT" href="javascript:;">结合障害</a>
                </span>
                <a id="BtnAddBug" href="javascript:;" class="layui-btn layui-btn-normal" style="float:right">
                    <i class="layui-icon layui-icon-add-circle"></i> 录入障害
                </a>
            </div>
            <div class="layui-form layui-form-pane">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">完了件数</label>
                        <div class="layui-input-block" style="width:80px">
                            <input id="confirms" class="layui-input" readonly="readonly" value="" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">未解决件数</label>
                        <div class="layui-input-block" style="width:80px">
                            <input id="noConfirms" class="layui-input" readonly="readonly" value="" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">障害总件数</label>
                        <div class="layui-input-block" style="width:80px">
                            <input id="bugnums" class="layui-input" readonly="readonly" value="" />
                        </div>
                    </div>
                </div>
            </div>
            <table id="bugs" lay-filter="bugs"></table>
        </div>      
    </div>
    <script type="text/html" id="toolbarDemo">
        <b>@Model.Name 项目障害一览</b>
    </script>
    <script type="text/html" id="BugNoTpl">
        <a href="#" class="layui-table-link" lay-event="edit">{{d.No || ''}}</a>
    </script>   
</div>
@section scripts{
    <script>
        layui.use(['jquery', 'form', 'table', 'dropdown'], function () {
            var table = layui.table;
            var $ = layui.jquery;
            var dropdown = layui.dropdown;
            var pid = '@Model.Id';
            table.render({
                elem: '#bugs'
                , height: 550
                , title: '项目障害一览'
                , page: {}
                , limits: [10]
                , url: '/Project/BugList?hid=' + pid
                , autoSort: false
                , toolbar: '#toolbarDemo'
                , defaultToolbar: ['filter', 'exports', 'print']
                , cols: [[
                    { type: 'numbers', fixed: 'left' }
                    , { field: 'No', title: '番号', width: 100, fixed: 'left', templet: '#BugNoTpl' }
                    , { field: 'PageId', title: '机能ID', width: 150 }
                    , { field: 'PageName', title: '机能名', width: 200 }                  
                    , { field: 'HappenDay', title: '发生日', width: 110 }
                    , { field: 'IssuerName', title: '发行者', width: 90 }
                    , { field: 'PriorityName', title: '优先级', width: 80 }
                    , { field: 'BookEndDate', title: '预定完了日', width: 110 }
                    , { field: 'ConfirmDay', title: '确认日', width: 110 }
                    , { field: 'ConfirmUserName', title: '确认者', width: 100 }
                    , { field: 'SceneKindName', title: '现象区分', width: 120 }
                    , { field: 'ReasonSmallName', title: '原因区分(小)', width: 120 }
                    , { field: 'BugKindName', title: '障害区分', width: 120 }                   
                    , { field: 'ReviseUserName', title: '修正者', width: 90 }
                    , { field: 'ReviseDay', title: '修正日', width: 110 }
                    , { field: 'ReasonBigName', title: '原因区分(大)', width: 120 }
                    , { field: 'AcceptUserName', title: '承认者', width: 120 }
                    , { field: 'IsUnfoldName', title: '展开要否', width: 100 }
                    , { field: 'UnfoldNo', title: '展开番号', width: 100 }
                    , { field: 'StatusName', title: '状态', width: 100 }
                    , { field: 'Remark', title: '备注', width: 200 }
                ]]
                , done: function (res) {
                    setTotolInfo(res.data);
                }
            });

            //监听行工具事件
            table.on('tool(bugs)', function (obj) {
                var data = obj.data;
                if (obj.event === 'edit') {
                    redirect('Project', 'BugInfo', pid, data.No, $(".tab-this").attr("id"));
                } 
            });

            $("#tabs").find("a").click(function () {
                $("#tabs").find("a").removeClass("tab-this");
                $(this).addClass("tab-this");
                var kind = $(".tab-this").attr("id");
                table.reload('bugs', {
                    url: '/Project/BugList?hid=' + pid + '&kind=' + kind
                    , page: { curr: 1 }
                    , done: function (res) {
                        setTotolInfo(res.data);
                    }
                });
            });
              
            dropdown.on('click(chartMenu)', function (options) {
                var kind = options.id;
                var pro = $(".tab-this").attr("id");
                layer.open({
                    type: 2,
                    title: options.txt,
                    maxmin: false,
                    area: ['1000px', '600px'],
                    content: '/Project/Analysis?id=' + pid + '&kind=' + kind + "&pro=" + pro          
                });               
            });

            $("#BtnAddBug").click(function () {
                redirect('Project', 'BugInfo', pid, '', $(".tab-this").attr("id"));
            });

            function setTotolInfo() {
                var pro = $(".tab-this").attr("id");
                getPost('/Project/BugTotol', { pid: pid, pro: pro}, function (res) {
                    if (res.status === 0) {
                        $("#bugnums").val(res.totol);
                        $("#confirms").val(res.confirm);
                        $("#noConfirms").val(res.totol - res.confirm);                        
                    }
                });
            }
        });
    </script>
}

